#include <iostream>
using namespace std;

const int N = 110;

int n, m;
int a[N][N];
int f[N][N];

// 方向向量
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};

int dfs(int i, int j)
{
	if (f[i][j]) return f[i][j];
	int len = 1;
	for (int k = 0; k < 4; k++)
	{
		int x = i + dx[k], y = j + dy[k];
		// 判断边界值
		if (x < 1 || x > n || y < 1 || y > m)	continue;
		if (a[i][j] <= a[x][y])	continue;
		len = max(dfs(x, y) + 1, len);
	}
	return f[i][j] = len;
}

int main()
{	
	cin >> n >> m;

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			cin >> a[i][j];

	int ret = 0;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			ret = max(ret, dfs(i, j));

	cout << ret << endl;

	return 0;
}